package com.qf.lja.servlet;

import com.qf.lja.dao.OrderDao;
import com.qf.lja.dao.ProductDao;
import com.qf.lja.enity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;


@WebServlet(urlPatterns = "/ReGood")
public class ReceivGoodsServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //确认收货
        String o_id = req.getParameter("o_id");
        ProductDao productDao = new ProductDao();
        productDao.updateGoodstatus(o_id, 3);

        HttpSession session = req.getSession();
        User user = (User) session.getAttribute("user");

        OrderDao orderDao = new OrderDao();

        req.setAttribute("orderList", orderDao.findOrderList(user.getUserId()));

        req.getRequestDispatcher("/orderList.jsp").forward(req, resp);
    }
}
